import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;


/**
 * This class is class UI
 */
	public class ClassUI  extends JPanel {
		/**
		 * title for the current window  
		 */
		private JLabel lbltitle = null;
		/**
		 * label for the id  
		 */
		private JLabel lblID = null;
		/**
		 * label for the name  
		 */
		private JLabel lblName = null;
		/**
		 * TextField for the id  
		 */
		private JTextField TextID = null;
		/**
		 * TextField for the name  
		 */
		private JTextField TextName = null;
		/**
		 * add class button
		 */
		private JButton btnAddClass = null;
		/**
		 * back button
		 */
		public JButton btnBack = null;
		/**
		 * help button
		 */
		public JButton btnHelp = null;
		
		private String id;
		private String name;


		
		/**
		* Constructs
		*/
		public ClassUI () {
			super();
			initialize();
		}
		
		private void initialize() {
			
			btnAddClass = new JButton();
			/**
			 *  add class button Implementation
			 */
			btnAddClass.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					Cls cls = new Cls(id,name);
					SQL s = new SQL(cls,14);
					s.accept();
					System.out.println("here  " + s.getMsg());
					if ("classCreate".equals(s.getMsg()))
					{
						AddStudentUI addStudentUI = new AddStudentUI(id,3);
						System.out.println("add class");
						setVisible(false);
						Global.main.setContentPane(addStudentUI);
					}
				}
			});
			btnAddClass.setBounds(new Rectangle(109, 196, 200, 25));
			btnAddClass.setText("Add Class");
			this.add(btnAddClass,null);
			this.setVisible(true);
			
			lblID = new JLabel("Class ID:");
			lblID.setBounds(83, 60, 110, 14);
			this.add(lblID);	
				
			TextID = new JTextField();
			TextID.setBounds(new Rectangle(194, 60, 128, 25));
			TextID.addFocusListener(new java.awt.event.FocusAdapter() 
			{
				public void focusLost(java.awt.event.FocusEvent e) 
				{
					System.out.println("focusLost()"); 
					id=TextID.getText();			
				}
			}
			);
			this.add(TextID,null);
			
			
			lblName = new JLabel("Class Name:");
			lblName.setBounds(83, 100, 110, 14);
			this.add(lblName);	
			
			TextName = new JTextField();
			TextName.setBounds(new Rectangle(194, 100, 128, 25));
			TextName.addFocusListener(new java.awt.event.FocusAdapter() 
			{
				public void focusLost(java.awt.event.FocusEvent e) 
				{
					System.out.println("focusLost()"); 
					name = TextName.getText();
				}
			}
			);
			this.add(TextName,null);
			
			
			

			lbltitle = new JLabel("Add Class");
			lbltitle.setBounds(156, 24, 110, 14);

			this.setSize(400, 321);
			this.setLayout(null);
			
			this.add(lbltitle);
			/**
			 *  back button Implementation
			 */
			btnBack = new JButton("Back");
			btnBack.setBounds(167, 272, 86, 25);
			this.add(btnBack,null);
			this.setVisible(true);
			/**
			 *  help button Implementation
			 */
			btnHelp = new JButton("Help");
			btnHelp.setBounds(390, 11, 80, 19);
			btnHelp.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					  HelpWin help = new HelpWin ("Enter the Class details and then ","click on 'Add Class' button");
					  System.out.println("user press Help button");
				}
			});
			this.add(btnHelp,null);
			this.setVisible(true);
			
		}
	}



